package com.xcesys.extras.dataobject.system;

import java.util.Collection;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

import com.xcesys.extras.dataobject.EditableObject;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Role")
public class Role extends EditableObject implements java.io.Serializable {

	private static final long serialVersionUID = -4660384082102438948L;
	public static final String F_NAME = "name";
	public static final String F_DESCRIPTION = "description";
	@XmlAttribute(name = "Description")
	private String description;

	@XmlAttribute(name = "Name")
	private String name;

	private Collection<Permission> pemissions = null;

	private Collection<Resource> resources = null;

	private Collection<User> users = null;

	public Role() {
	}

	public String getDescription() {
		return description;
	}

	public String getName() {
		return name;
	}

	public Collection<Permission> getPemissions() {
		return pemissions;
	}

	public Collection<Resource> getResources() {
		return resources;
	}

	public Collection<User> getUsers() {
		return users;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setName(String nameEn) {
		this.name = nameEn;
	}

	public void setPemissions(Collection<Permission> pemissions) {
		Object oldValue = this.pemissions;
		this.pemissions = pemissions;
		firePropertyChange("pemissions", oldValue, pemissions);
	}

	public void setResources(Collection<Resource> resources) {
		this.resources = resources;
	}

	public void setUsers(Collection<User> users) {
		this.users = users;
	}

	/**
	 * Constructs a <code>String</code> with all attributes in name = value
	 * format.
	 * 
	 * @return a <code>String</code> representation of this object.
	 */
	@Override
	public String toString() {
		final String TAB = "    ";

		String retValue = "";

		retValue = "Role ( " + super.toString() + this.name + TAB
				+ "description = " + this.description + TAB + "resources = "
				+ this.resources + TAB + "users = " + this.users + TAB + " )";

		return retValue;
	}

}
